/**  \file appdata.h
\brief Application data Class

Price My House for Nokia mobile platforms.

\author © 2011 Enrico Miglino / Tech Consulting (enrico.miglino@ovi.com)
\author "Evimin Fiyati Price My House" is protected by the copyright law
\author Distributed under the LGPL 3.0 license.
\date 2011

\par Licensing notes

    "Price My House" is free software: you can redistribute it
    and/or modify it under the terms of the Lesser GNU General Public License
    as published by the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    "Price My House" is distributed in the hope that it
    will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    Lesser GNU General Public License for more details.

    You should have received a copy of the Lesser GNU General Public License
    along with "Price My House".
    If not, see <http://www.gnu.org/licenses/>.

*/

#ifndef APPDATA_H
#define APPDATA_H

#include <Qt>
#include <QObject>
#include <QByteArray>
#include <QApplication>
#include <QFile>
#include <QTextCodec>
#include <QtDebug>

//! \def FILE_EXTENSION
//! \brief Default extension for the data files
#define FILE_EXTENSION ".json"

/**
  \class AppData : public QObject
  \brief Data application manager

  This class contains properties and methods to manage the
  Json files with the combo informations to setup the variable
  strings in the application.
  Extends the QObject class to be imported and managed by the
  QML UI.

 */
class AppData : public QObject
{
    Q_OBJECT
    // Declares the properties exported to QML and associated methods
    Q_PROPERTY(QString fname READ fname WRITE setFname)
    Q_PROPERTY(QString language READ language WRITE setLanguage)
    Q_PROPERTY(QString folder READ folder WRITE setFolder)
    Q_PROPERTY(QString datafile READ datafile)
    Q_PROPERTY(QString datastream READ datastream)

public:
    explicit AppData(QObject *parent = 0);

    QString fname() const;
    QString language() const;
    QString folder() const;
    QString datastream() const;
    QString datafile() const;
    void setFname(const QString &);
    void setLanguage(const QString &);
    void setFolder(const QString &);
    Q_INVOKABLE void createConfFile();
    Q_INVOKABLE void getJson();
private:
    /**
    \var QString m_fname, m_language, m_folder, m_data, m_datastream
    \brief Private strings used to create the configuration file name
    and manage the data stream.

    These are respectively:
     - m_fname The exclusive file name (i.e. 'datafile)
     - m_language The two character language code (i.e. 'en')
     - m_folder The configuration folder path (i.e. 'data/config/')
     - m_data The full file name
     - m_datastream The json data read from the file.
     */
    QString m_fname, m_language, m_folder, m_data, m_datastream;
    QString buildFName();
signals:
public slots:
};

#endif // APPDATA_H
